---
title: "**Offence:** Possession of Weapon"
output:
flexdashboard::flex_dashboard:
self_contained: true
orientation: rows
source: embed
social: menu
bibliography: ../references/references.bib
---
```{r setup, include=FALSE}
packages = c("dplyr", "rgdal", "knitr",
"sf", "viridis", "ggeasy",
"tidyr","scales",
"etasFLP","maptools","sp",
"raster","leaflet","htmlwidgets",
"htmltools", "ggplot2",
"flexdashboard", "tidyverse",
"leaflet.minicharts", "manipulateWidget")
## Now load or install&load all
package.check <- lapply(
packages,
FUN = function(x) {
if (!require(x, character.only = TRUE)) {
install.packages(x, dependencies = TRUE)
library(x, character.only = TRUE)
}
}
)
# Setup knitr
knitr::opts_chunk$set(
echo = FALSE, message = FALSE, warning = FALSE,
# Save all figures in the output dir, you have to include them explicitly
# with an <img> tag
fig.path = "../output/img/", fig.show = "show"
)
```
```{r, include=FALSE}
#generate all the necessary tables
#setting work directory
pasteo <- "R:/HLSS/Big Data Centre/Data/TRANSFER_FROM_SERVER_ROOM/20221014/GMP/AMO/"
#load all boundary shapefile
#load gm boundary
gm_bdry <- sf::read_sf(paste(pasteo, "boundaries/", "GMP_BOUNDARY_geo", ".shp", sep=""))
#load la boundary
gm_la <- sf::read_sf(paste(pasteo, "boundaries/", "GM_LA_geo", ".shp", sep=""))
#load wards boundary
gm_ward <- sf::read_sf(paste(pasteo, "boundaries/", "gm_ward_geo", ".shp", sep=""))
#load lsoa boundary
gm_lsoa <- sf::read_sf(paste(pasteo, "boundaries/", "GMP_LSOA_BOUNDARY_geo", ".shp", sep=""))
#load city centre boundary
gm_centre <- sf::read_sf(paste(pasteo, "boundaries/", "city_and_town_Centre_merged2", ".shp", sep=""))
```
```{r, include=FALSE}
library(crosstalk)
library(leaflet)
library(dplyr)
library(reactable)
#SharedData$n
breweries91 <- leaflet::breweries91
# A SpatialPointsDataFrame for the map.
# Set a group name to share data points with the table.
brew_sp <- SharedData$new(breweries91, group = "brewery")
# A regular data frame (without coordinates) for the table.
# Use the same group name as the map data.
brew_data <- as_tibble(breweries91) %>%
dplyr::select(brewery, address, village, founded) %>%
SharedData$new(group = "brewery")
#head(brew_data)
map <- leaflet(brew_sp) %>%
addTiles() %>%
addMarkers()
##map
#
tbl <- reactable(
brew_data,
selection = "multiple",
onClick = "select",
rowStyle = list(cursor = "pointer"),
minRows = 10
)
#
```
## Row 1 {data-height=80}
### Offence per 1,000 people (LSOA units) {data-width=1200}
```{r, include=TRUE}
# mm1 <- htmltools::browsable(
# htmltools::tagList(map, tbl)
# #htmltools::tagAppendChild(tag1, tbl)
# )
# mm1
```
### Offence per 1,000 people (Ward units)
## Row 2 {data-height=150}
### Offence per 1,000 people (LSOA units){data-width=200}
```{r eval=FALSE}
# #render map
# map3 <- leaflet() %>%
# addTiles %>%
# addPolygons(data = bckgrnd2, #
# color="white",
# #label = ~FILE_NAME,
# labelOptions = labelOptions(
# noHide = T, textOnly = T,
# textsize = 22,
# style = list('color' = "white")
# ),
# ##color = ~colorQuantile("gray", gm_la$FILE_NAME)(FILE_NAME),
# fillOpacity = 1,
# group = "background")%>%
# #addProviderTiles(providers$CartoDB.Positron) %>%
# addPolygons(data = gm_la %>% filter(FILE_NAME == "ROCHDALE"), weight = 1, #all la boundaries
# color="black",
# #label = ~FILE_NAME,
# labelOptions = labelOptions(
# noHide = T, textOnly = T,
# textsize = 22,
# style = list('color' = "black")
# ),
# ##color = ~colorQuantile("gray", gm_la$FILE_NAME)(FILE_NAME),
# fillOpacity = 0.1,
# group = "la")
# # addTiles %>%
# # setView(-2.271, 53.504, zoom = 1.5) %>% syncWith("maps")%>%
# # addPolygons(data = gm_bdry, #
# # color="white",
# # #label = ~FILE_NAME,
# # labelOptions = labelOptions(
# # noHide = T, textOnly = T,
# # textsize = 22,
# # style = list('color' = "white")
# # ),
# # ##color = ~colorQuantile("gray", gm_la$FILE_NAME)(FILE_NAME),
# # fillOpacity = 1,
# # group = "background")#%>%
#
# map3
```
```{r, include=TRUE}
mm2 <- htmltools::browsable(
#attachDependencies(map,
htmltools::tagList(map, tbl))
#htmltools::tagAppendChild(tag1, tbl)
#)
mm2
```
### Offence per 1,000 people (Ward units) {data-width=100}
```{r, include=TRUE, fig.width=2, fig.height=2}
mm2 <- htmltools::tagList(tbl)
mm2
```
## Row 3 {data-height=100}
### Offence per 1,000 people (LSOA units)
### Offence per 1,000 people (Ward units)
### Offence per 1,000 people (Ward units)
<!-- **References** -->